<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<xblock>
        <span class="x-right" style="line-height:40px">共有数据：${total} 页</span>
      </xblock>
<table class="layui-table" >
<thead>
          <tr>
            <th>
              <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>
            <th>订单号</th>
            <th>微信昵称</th>
            <th>处方</th>
            <th>地址</th>
            <th>订单状态</th>
            <th>购买数量</th>
            <th>线下</th>
            <th>医生姓名</th>
            <th>操作</th></tr>
        </thead>
        <tbody>
        <c:if test="${not empty list}">
      	<c:forEach var="app" items="${list}" varStatus="st">
      	<c:choose>
      		<c:when test="${app.orderState==2}">
      			 <tr style="color:red;">
            <td>
              <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='2'><i class="layui-icon">&#xe605;</i></div>
	            </td>
	            <td>${app.id}</td>
	            <td>${app.weName}</td>
	            <td><img src="${pageContext.request.contextPath }${app.chufangPic}" alt="" width="70" height="50" /></td>
	            <td>${app.addressDetail}</td>
	            <td>
	            <span><c:choose>  
		  			<c:when test="${app.orderState==1}"> 
		  				未支付  
		  			</c:when> 
		  			<c:when test="${app.orderState==2}"> 
		  				未审核
		  			</c:when>
		  			<c:when test="${app.orderState==3}"> 
		  				已审核  
		  			</c:when>
		  			<c:when test="${app.orderState==4}">
		  				未发货   
		  			</c:when>
					<c:when test="${app.orderState==5}"> 
		  				已发货 
		  			</c:when>
		  			<c:when test="${app.orderState==6}"> 
		  				已完成
		  			</c:when>
		  			<c:when test="${app.orderState==7}"> 
		  				已退货
		  			</c:when>
			  			<c:when test="${app.orderState==8}"> 
			  				审核不通过
			  			</c:when>
			  <c:otherwise> 
			  	订单出问题  
			  </c:otherwise> 

			</c:choose> 
		</span>
	            </td>
	            <td>${app.orderSum}</td>
	            <td>
	             <c:choose>
          			<c:when test="${!empty app.orderYuliu}">
          			自取
          			</c:when>
         			<c:otherwise>
         			配送
        			 </c:otherwise>
          			</c:choose></td>
          			<td>${app.doctorName}</td>
	            <td class="td-manage">
	              <a title="审核"  onclick="x_admin_show('审核','/admin/orderDetail?id=${app.id}',600,400)" href="javascript:;">
	                <i class="layui-icon">&#xe642;</i>
	              </a>
	              <a title="更新状态" onclick="my_show('更新状态','/admin/orderState?id=${app.id}',500,400)" href="javascript:;">
	                <i class="layui-icon">&#xe631;</i>
	              </a>
	              <a title="打印" onclick="member_print(this,'${app.id}')" href="javascript:;">
	                <i class="layui-icon">&#xe60a;</i>
	              </a>
	            </td>
          </tr>
      		</c:when>
      		<c:otherwise>
      			<tr>
            <td>
              <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='2'><i class="layui-icon">&#xe605;</i></div>
	            </td>
	            <td>${app.id}</td>
	            <td>${app.weName}</td>
	            <td><img src="${pageContext.request.contextPath }${app.chufangPic}" alt="" width="70" height="50" /></td>
	            <td>${app.addressDetail}</td>
	            <td>
	            <span><c:choose>  
		  			<c:when test="${app.orderState==1}"> 
		  				未支付  
		  			</c:when> 
		  			<c:when test="${app.orderState==2}"> 
		  				未审核
		  			</c:when>
		  			<c:when test="${app.orderState==3}"> 
		  				已审核  
		  			</c:when>
		  			<c:when test="${app.orderState==4}">
		  				未发货   
		  			</c:when>
					<c:when test="${app.orderState==5}"> 
		  				已发货 
		  			</c:when>
		  			<c:when test="${app.orderState==6}"> 
		  				已完成
		  			</c:when>
		  			<c:when test="${app.orderState==7}"> 
		  				已退货
		  			</c:when>
			  			<c:when test="${app.orderState==8}"> 
			  				审核不通过
			  			</c:when>
			  			<c:when test="${app.orderState==9}"> 
			  				待退款
			  			</c:when>
			  <c:otherwise> 
			  	订单出问题  
			  </c:otherwise> 

			</c:choose> 
		</span>
	            </td>
	            <td>${app.orderSum}</td>
	            <td>
	             <c:choose>
          			<c:when test="${!empty app.orderYuliu}">
          			自取
          			</c:when>
         			<c:otherwise>
         			配送
        			 </c:otherwise>
          			</c:choose></td>
          			<td>${app.doctorName}</td>
	            <td class="td-manage">
	              <a title="审核"  onclick="x_admin_show('审核','/admin/orderDetail?id=${app.id}',600,400)" href="javascript:;">
	                <i class="layui-icon">&#xe642;</i>
	              </a>
	              <a title="更新状态" onclick="my_show('更新状态','/admin/orderState?id=${app.id}',500,400)" href="javascript:;">
	                <i class="layui-icon">&#xe631;</i>
	              </a>
	              <a title="打印" onclick="member_print(this,'${app.id}')" href="javascript:;">
	                <i class="layui-icon">&#xe60a;</i>
	              </a>
	            </td>
          </tr>
      		</c:otherwise>
      	</c:choose>
          </c:forEach>
	      </c:if>
        </tbody>
        </table>
          <div class="page">
        <div>
          <a class="my-first" href="javascript:;">
          	首页</a>
          <a class="prev" href="javascript:;">上一页</a>
          <a class="next" href="javascript:;">下一页</a>
          <a class="my-last" href="javascript:;">末页</a>
        </div>
      </div>
        <script>
        //打印页面
        function member_print(obj,id){
        	var printUrl ="/admin/orderPrint?id="+id;
        	$.get(printUrl,function(data){
        		if("error"!=data){
        			window.location.href=data;
        		}else{
        			 layer.msg('打印失败!',{icon:1,time:1000});
        		}
        	});
        }
  		$('.my-first').click(function(){
  			var page =${page};
  			var state =$("#my_state").val();
  			var id =$('#my_search').val();
  			if(page>1){
  				$("#hh").val(1);
  				myUrl(1,id,state);
  			}
  		});
  		$('.prev').click(function(){
  			var page =${page};
  			var state =$("#my_state").val();
  			var id =$('#my_search').val();
  			if(page>=2){
  				myUrl(page-1,id,state);
  			}
  		});
  		$('.next').click(function(){
  			var page =${page};
  			var total=${total};
  			var state =$("#my_state").val();
  			var id =$('#my_search').val();
  			if(total>=2&&page<total){
  				myUrl(page+1,id,state);
  			}
  		});
  		$('.my-last').click(function(){
  			var page =${page};
  			var total=${total};
  			var state =$("#my_state").val();
  			var id =$('#my_search').val();
  			if(total>=2){
  				myUrl(total,id,state);
  			}
  		}); 
  		
  		function myUrl(start,id,state){
  			var url="/admin/orderTable?start="+start+"&id="+id+"&state="+state;
		    	$.get(url,function(data){
		    		$('#my_table').html(data);
		    	});
  		}
  		
  		function my_show(title,url,w,h){
  			var state =$("#my_state").val();
  			var page =${page};
  			layer.open({
  		      type: 2,
  		      title: title,
  		      shadeClose: false, //点击遮罩关闭
  		      shade: 0.8,
  		      area: [w+'px', h +'px'],
  		      maxmin: true,
  		      closeBtn: 1,
  		      content: [url, 'yes'], //iframe的url，yes是否有滚动条
  		      end: function () {
  		    	myUrl(page,"",state);
  		      }
  		});

  		}
        </script>